<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="include::head"></head>
<body>
<div class="layui-fluid layui-anim layui-anim-upbit">
    <div class="layui-row layui-col-space15 table-search">
        <div class="layui-col-md12">
            <form class="layui-form" id="from-search">
                <div class="layui-form-item">

                    <div class="layui-input-inline">
                        <input class="layui-input" name="title" placeholder="请输入标题名称..." autocomplete="off">
                    </div>

                    <div class="layui-input-inline">
                        <input class="layui-input" name="nickname" placeholder="请输入发布人..." autocomplete="off">
                    </div>

                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="type" th:with="word=${diy['bulletin_type']}">
                                <option value="">全部类别</option>
                                <option th:each="value : ${word}" th:value="${value.dictionaryRoute}" th:utext="${value.dictionaryName}"></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="isSetTop" th:with="word=${diy['set_top_type']}">
                                <option value="">是否置顶</option>
                                <option th:each="value : ${word}" th:value="${value.dictionaryRoute}" th:utext="${value.dictionaryName}"></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="isState" th:with="word=${diy['state_type']}">
                                <option value="">全部状态</option>
                                <option th:each="value : ${word}" th:value="${value.dictionaryRoute}" th:utext="${value.dictionaryName}"></option>
                            </select>
                        </div>
                    </div>

                    <button class="layui-btn" id="form-submit" lay-submit  lay-filter="search">
                        <i class="layui-icon layui-icon-search"></i>
                    </button>

                    <button class="layui-btn" lay-filter="refresh">
                        <i class="layui-icon layui-icon-refresh"></i>
                    </button>

                </div>
            </form>

            <div class="layui-btn-group" lay-filter="button-demo">
                <th:block th:each="button : ${button}" th:if="${button.type == 'tool_button'}">
                    <th:block th:if="${button.eventType == 'event_export'}">
                        <a th:class="${button.perClass +' '+ button.eventType}" th:href="${button.perHref}" th:utext="${button.perName}"></a>
                    </th:block>
                    <th:block th:if="${button.eventType != 'event_export'}">
                        <button th:class="${button.perClass +' '+ button.eventType}" th:href="${button.perHref}" th:value="${button.perName}" th:utext="${button.perName}"></button>
                    </th:block>
                </th:block>
            </div>
            <table class="layui-hide" id="table" lay-filter="demo"></table>
        </div>
    </div>
</div>
<div th:include="include::onload"></div>
<script type="text/html" id="barDemo">
    <button th:each="button : ${button}" th:if="${button.type == 'menu_button'}" th:class="${button.perClass}" th:href="${button.perHref}" th:lay-event="${button.eventType}" th:value="${button.perName}" th:utext="${button.perName}"><i th:class="${button.perIcon}"></i></button>
</script>
<script  th:inline="javascript">
    layui.config({
        base: '/js/layer/module/'//模块存放的目录
    }).use(['tabular','table'], function(){
        var tabular = layui.tabular,
            statetype = [[${diy['state_type']}]],
            bulletintype = [[${diy['bulletin_type']}]],
            settoptype = [[${diy['set_top_type']}]],
            url = "/admin/basics/bulletin",
            options = {
                elem: '#table',
                url:url,
                onlyId:"bulletinId",
                method:'post',
                id:'bulletin-table',
                height: 'full-150',
                cellMinWidth: 100,
                cols:[
                    [
                        {type:'numbers',title: '序号', fixed: 'left'}
                        ,{field:'title',fixed: 'left',title: '标题', sort: true}
                        ,{field:'content',title: '内容', sort: true}
                        ,{field:'enclosure', title: '附件',sort: true}
                        ,{field:'type', title: '类别',sort: true,templet: function (option) {
                            return $.common.initDity(bulletintype,option.type,option.bulletinId);
                        }}
                        ,{field:'nickname',title: '发布人', sort: true}
                        ,{field:'sort',title: '排序',sort: true}
                        ,{field:'isSetTop',align:'center', title: '置顶',sort: true,templet: function (option) {
                            return $.common.initState(settoptype,option.isSetTop,option.bulletinId);
                        }}
                        ,{field:'isState',align:'center', title: '状态',sort: true,templet: function (option) {
                            return $.common.initState(statetype,option.isState,option.bulletinId);
                        }}
                        ,{field:'addDate', title: '发布时间',fixed: 'right', sort: true,templet: function (option) {
                            return $.date.stringDate(option.addDate);
                        }}
                        ,{width:'10%', align:'center',fixed: 'right', toolbar: '#barDemo'}
                    ]
                ],
                ispage:true
            };
        //初始化表格
        tabular.init(options);
        //监听搜索
        tabular.search();
        //工具按钮监听
        tabular.button();
        //开关按钮监听
        tabular.switch(url+"/update");
    });

</script>
</body>
</html>